home *** CD-ROM | disk | FTP | other *** search
/ Champak Vol E-12 / Vol E-12.iso / games / barbie / barbie_l.swf / scripts / frame_1 / DoAction.as
Text File  |  2012-05-21  |  4KB  |  168 lines

  1. function move()
  2. {
  3.    _root.nextr = _root.oldrows + _root.dirr;
  4.    _root.nextc = _root.oldcols + _root.dirc;
  5.    if(8 < _root.grid[_root.nextr][_root.nextc])
  6.    {
  7.       _root.grid[_root.oldrows][_root.oldcols] = _root.prevplace;
  8.       _root.prevplace = _root.grid[_root.nextr][_root.nextc];
  9.       _root.grid[_root.nextr][_root.nextc] = 9;
  10.       _root.oldrows = _root.nextr;
  11.       _root.oldcols = _root.nextc;
  12.       with(_root.man)
  13.       {
  14.          play();
  15.       }
  16.    }
  17.    else
  18.    {
  19.       trace("wall");
  20.       _root.reset = 0;
  21.    }
  22. }
  23. function setup(num)
  24. {
  25.    startx = 300;
  26.    starty = 150;
  27.    _root.countup = 0;
  28.    i = 0;
  29.    while(i < _root.rows)
  30.    {
  31.       _root.newstartx = _root.startx - i * 30;
  32.       _root.newstarty = _root.starty + i * 15;
  33.       k = 0;
  34.       while(k < _root.cols)
  35.       {
  36.          _root.attachMovie("square" + num,"sq" + _root.countup,_root.countup * 2);
  37.          setProperty(eval("_root.sq" + _root.countup), _X, _root.newstartx + k * 30);
  38.          setProperty(eval("_root.sq" + _root.countup), _Y, _root.newstarty + k * 15);
  39.          whatamic = _root.countup % _root.cols;
  40.          whatamir = Math.floor(_root.countup / _root.rows);
  41.          whatami = _root.grid[whatamir][whatamic];
  42.          with(eval("_root.sq" + _root.countup))
  43.          {
  44.             gotoAndStop(whatami);
  45.          }
  46.          with(_root.walls)
  47.          {
  48.             gotoAndStop(num);
  49.          }
  50.          _root.countup += 1;
  51.          k++;
  52.       }
  53.       i++;
  54.    }
  55.    _root.fadein = 1;
  56. }
  57. function direction()
  58. {
  59.    if(_root.dir == 1)
  60.    {
  61.       _root.dirc = 0;
  62.       _root.dirr = -1;
  63.       _root.reset = 0;
  64.       with(_root.man)
  65.       {
  66.          gotoAndStop("up");
  67.       }
  68.    }
  69.    if(_root.dir == 2)
  70.    {
  71.       _root.dirc = 1;
  72.       _root.dirr = 0;
  73.       _root.reset = 0;
  74.       with(_root.man)
  75.       {
  76.          gotoAndStop("right");
  77.       }
  78.    }
  79.    if(_root.dir == 3)
  80.    {
  81.       _root.dirc = 0;
  82.       _root.dirr = 1;
  83.       _root.reset = 0;
  84.       with(_root.man)
  85.       {
  86.          gotoAndStop("down");
  87.       }
  88.    }
  89.    if(_root.dir == 4)
  90.    {
  91.       _root.dirc = -1;
  92.       _root.dirr = 0;
  93.       _root.reset = 0;
  94.       with(_root.man)
  95.       {
  96.          gotoAndStop("left");
  97.       }
  98.    }
  99. }
  100. function stage1()
  101. {
  102.    _root.turtle = 0;
  103.    _root.door = 0;
  104.    _root.dir = 4;
  105.    _root.direction();
  106.    _root.bell = 0;
  107.    _root.prevplace = 10;
  108.    bridge = 0;
  109.    with(_root.walls.port)
  110.    {
  111.       gotoAndStop(1);
  112.    }
  113.    _root.r0 = "1,1,1,1,1,1,1,1,1,1,1";
  114.    _root.r1 = "1,10,10,10,10,15,10,10,10,10,1";
  115.    _root.r2 = "1,2,2,2,2,10,14,10,2,2,1";
  116.    _root.r3 = "1,11,11,11,11,11,12,11,11,11,1";
  117.    _root.r4 = "1,11,11,11,11,11,12,11,11,11,1";
  118.    _root.r5 = "1,11,11,11,11,11,12,11,11,11,1";
  119.    _root.r6 = "1,2,2,2,2,10,10,10,2,2,1";
  120.    _root.r7 = "1,10,10,10,10,10,10,10,10,10,1";
  121.    _root.r8 = "1,10,10,10,10,10,10,10,2,10,1";
  122.    _root.r9 = "1,10,10,10,10,9,10,10,2,13,1";
  123.    _root.r10 = "1,1,1,1,1,1,1,1,1,1,1";
  124.    i = 0;
  125.    while(i < rows)
  126.    {
  127.       var temp = eval("_root.r" + i);
  128.       _root.grid[i] = temp.split(",");
  129.       i++;
  130.    }
  131.    i = 0;
  132.    while(i < rows)
  133.    {
  134.       k = 0;
  135.       while(k < cols)
  136.       {
  137.          _root.grid[i][k] = Number(_root.grid[i][k]);
  138.          k++;
  139.       }
  140.       i++;
  141.    }
  142.    setup(1);
  143.    _root.man.begin();
  144. }
  145. function killme()
  146. {
  147.    trace("killme called");
  148.    with(_root.man)
  149.    {
  150.       gotoAndPlay("gareth");
  151.    }
  152.    with(_root.man)
  153.    {
  154.       play();
  155.    }
  156. }
  157. grid = new Array();
  158. rows = 11;
  159. cols = 11;
  160. reset = 1;
  161. _root.mystage = 1;
  162. _root.countup = 0;
  163. _root.startup = 0;
  164. _root.fadein = 0;
  165. _root.fadeout = 0;
  166. totalcells = rows * cols;
  167. stop();
  168.